package com.dwd.user.service.impl;

import com.dwd.basic.exception.CustomException;
import com.dwd.basic.service.impl.BaseServiceImpl;
import com.dwd.org.pojo.Employee;
import com.dwd.user.mapper.UserMapper;
import com.dwd.user.pojo.User;
import com.dwd.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Description: TODO
 * @Author 汶狄
 * @Date 2021/1/16 12:37
 * @Version 1.0
 */
@Service
public class UserServiceImpl extends BaseServiceImpl<User> implements IUserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 校验手机号码是否存在
     *
     * @param phone
     * @throws CustomException
     */
    @Override
    public void checkPhone(String phone) throws CustomException {
        if (StringUtils.isEmpty(phone)) {
            throw new CustomException("手机不能为空");
        }
        User user1 = userMapper.queryUserByPhone(phone);
        if (user1 != null) {
            throw new CustomException("用户已经注册了");
        }
    }




}
